package com.mini.controller;

import com.mini.bean.Leaves;
import com.mini.bean.OrderFrom;
import com.mini.service.LeavesService;
import com.mini.utils.ResultDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

//留言板
@RestController
@RequestMapping("/Leaves")
public class LeavesController {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private LeavesService leavesService;

    @RequestMapping(value ="/insertLeaves", method = RequestMethod.POST,produces= "application/json;charset=utf-8")
    @ResponseBody
    public ResultDTO insertLeaves(Leaves leaves) {

        try {
                leaves.setCreateTime(new Date());
            int a = leavesService.insertLeaves(leaves);
        }catch (Exception e){
            logger.info(""+e);
            return ResultDTO.getFailure("调用失败");
        }

        return ResultDTO.getSuccess(200,"成功");

    }

}
